package com.alibaba.serverless.service.handle.v20201108.impl;

import com.alibaba.serverless.common.util.CodeUtils;
import com.alibaba.serverless.domain.ReceiveParams;
import com.alibaba.serverless.service.handle.BaseSmtpStrategy;
import com.aliyuncs.dm.model.v20151123.BatchSendMailRequest;
import com.aliyuncs.dm.model.v20151123.SingleSendMailRequest;

/**
 * 邮件校验策略
 * @author mac_zyj
 */
public class IBaseSmtpCheckStrategyImpl extends BaseSmtpStrategy {
    @Override
    public SingleSendMailRequest sendSingleMailRequest(ReceiveParams smtpParams) {
        smtpParams.setCheckCode(CodeUtils.getSmtpCheckCode());
        SingleSendMailRequest request=initSingleSendMail(smtpParams);
        String fileKey = smtpParams.getFileKey();
        String httpBody =getHtmlBodyByUrl(fileKey,smtpParams.getFileLocation())
                .replace("[toAddress]", smtpParams.getToAddress()).replace("[code]",smtpParams.getCheckCode());
        request.setHtmlBody(httpBody);
        return request;
    }

    @Override
    public BatchSendMailRequest sendBatchMailRequest() {
        return null;
    }
}
